package com.mall.permission.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.mall.permission.model.RolePermission;
import com.mall.common.util.RespResult;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.mall.permission.service.IRolePermissionService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;


/**
 * <p>
 * URL权限关系对应 控制器
 * </p>
 *
 * @author Darren
 * @since 2022-10-20
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Api(tags = "REST - URL权限关系对应")
@RestController
@RequestMapping("/role-permission")
public class RolePermissionController {
    private final IRolePermissionService service;

    @PostMapping("/addRolePermission")
    @ApiOperation(value = "新增")
    public RespResult addRolePermission(@RequestBody RolePermission rolepermission){
        boolean flag = service.addRolePermission(rolepermission);
        return RespResult.ok(flag ? "创建成功" : "创建失败");
    }

    @PutMapping("/updateRolePermission")
    @ApiOperation(value = "更新")
    public RespResult updateRolePermission(@RequestBody RolePermission rolepermission){
        boolean flag = service.updateRolePermission(rolepermission);
        return RespResult.ok(flag ? "更新成功" : "更新失败");
    }

    @PostMapping("/selectList")
    @ApiOperation(value = "根据条件查询全部数据")
    public RespResult selectList(RolePermission rolepermission){
        return RespResult.ok(service.selectList(rolepermission));
    }

    @PostMapping("/selectPage")
    @ApiOperation(value = "分页查询")
    public RespResult selectPage(Page<RolePermission> page, RolePermission rolepermission){
        return RespResult.ok(service.selectPage(page, rolepermission));
    }

}